package easy.Excel表列序号;


public class Solution {
    public int titleToNumber(String columnTitle) {
        int result = 0;
        int len = columnTitle.length();
        for (int i = len - 1; i >= 0; i--) {
            result += (columnTitle.charAt(i) - 'A' + 1) * Math.pow(26, (len - i - 1));
        }
        return result;
    }

    public static void main(String[] args) {
        String columnTitle = "AB";
        String columnTitle2 = "ZY";
        Solution solution = new Solution();
        System.out.println(solution.titleToNumber(columnTitle));
        System.out.println(solution.titleToNumber(columnTitle2));
    }
}
